package cn.zbmao.web.dao.impl;

import cn.zbmao.web.bean.Constants;
import cn.zbmao.web.dao.HostDao;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HostDaoImpl implements HostDao {
    /**
     * 返回 Map<Integer,String>
     * 查询Host表中的id和Url字段并存入Map中，并返回
     * */
	@Override
	public Map<Integer, String> findHostMap(){
		Map<Integer, String> map = new HashMap<Integer, String>(); 
		List<Record> list = Db.find("select id,url from  " + Constants.HOST);
                                                    //host
		for (Record record : list) {
			map.put(record.getInt("id"), record.getStr("url"));
		}
		return map;
	}

}
